<?php

/**
 * This is class Form_Registry
 *
 */
class Form_Registry extends Zend_Form {
	/**
	 * This is method __construct
	 *
	 * @param mixed $options This is a description
	 * @return mixed This is the return value description
	 *
	 */	
	public function __construct($options = null) {
		parent::__construct($options);
		$this->setName('registry');
		
		$id = new Zend_Form_Element_Hidden('id');
		
		$userId = new Zend_Form_Element_Text('user_id');
		$userId->setLabel('User ID')
			->addFilter('StripTags')
			->addFilter('StringTrim');										
				
		$requesterName = new Zend_Form_Element_Text('requester_name');
		$requesterName->setLabel('Requester name')
			->addFilter('StripTags')
			->addFilter('StringTrim');
		
		$requesterEmail = new Zend_Form_Element_Text('requester_email');
		$requesterEmail->setLabel('Requester email')
			->addFilter('StripTags')
			->addFilter('StringTrim');	
			
		// Get the user info from the storage (session)  
		$storage = Zend_Auth::getInstance()->getStorage();	// storage of Zend_Auth
		if($storage) {
			$user = $storage->read();
			$userId->setValue($user->id);	
			$requesterName->setValue($user->full_name);
			$requesterEmail->setValue($user->email);
			
			$userId->setAttribs(array('disabled' => 'disabled'));
		}			
		
		$apiKey = new Zend_Form_Element_Text('api_key');
		$apiKey->setLabel('API key')
			->addFilter('StripTags')
			->addFilter('StringTrim');
		
		$apiSecret = new Zend_Form_Element_Text('api_secret');
		$apiSecret->setLabel('API secret')
			->addFilter('StripTags')
			->addFilter('StringTrim');			
		
		$callbackUri = new Zend_Form_Element_Text('callback_uri');
		$callbackUri->setLabel('Callback URI')
			->addFilter('StripTags')
			->addFilter('StringTrim');
		
		$appUri = new Zend_Form_Element_Text('app_uri');
		$appUri->setLabel('App URI')
			->addFilter('StripTags')
			->addFilter('StringTrim');
		
		$appTitle = new Zend_Form_Element_Text('app_title');
		$appTitle->setLabel('App title')
			->addFilter('StripTags')
			->addFilter('StringTrim');	
		
		$appDesc = new Zend_Form_Element_Text('app_desc');
		$appDesc->setLabel('App desc')
			->addFilter('StripTags')
			->addFilter('StringTrim');	
		
		$appNotes = new Zend_Form_Element_Text('app_notes');
		$appNotes->setLabel('App notes')
			->addFilter('StripTags')
			->addFilter('StringTrim');	
		
		$appLogo = new Zend_Form_Element_Text('app_logo');
		$appLogo->setLabel('App logo')
			->addFilter('StripTags')
			->addFilter('StringTrim');	
		
		$appType = new Zend_Form_Element_Text('app_type');
		$appType->setLabel('App type')
			->addFilter('StripTags')
			->addFilter('StringTrim');		
		
		$appConmmercial = new Zend_Form_Element_Checkbox('app_commercial');
		$appConmmercial->setLabel('App commercial')
			->addFilter('StripTags')
			->addFilter('StringTrim');
			
		$enabled = new Zend_Form_Element_Checkbox('enabled');
		$enabled->setLabel('Enabled')
			->addFilter('StripTags')
			->addFilter('StringTrim');																	
		
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setAttrib('class', 'submit')
			->setAttrib('id', 'submitButton');
		
		$this->addElements(array($id, $userId, $requesterName, $requesterEmail, 
			$callbackUri, $appUri, $appTitle, $appDesc, $appNotes, 
			$appLogo, $appType, $appConmmercial, $enabled, $submit));
	}
}